//
// UIScrollView+QSExtension.h
// QS_MGKit
//
// Created by Song on 2017/10/31.
// Copyright © 2017年 Song. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger, QSScrollDirection) {
    QSScrollDirection_Up,
    QSScrollDirection_Down,
    QSScrollDirection_Left,
    QSScrollDirection_Right
};

@interface UIScrollView (QSExtension)
/**
 *  ContentSize、ContentOffset
 */
@property(nonatomic, assign) CGFloat contentWidth;
@property(nonatomic, assign) CGFloat contentHeight;
@property(nonatomic, assign) CGFloat contentOffsetX;
@property(nonatomic, assign) CGFloat contentOffsetY;

/** 滚动方向 */
@property (nonatomic, assign, readonly) QSScrollDirection scrollDirection;

/**
 *  页码
 */
@property (nonatomic, assign, readonly) NSUInteger verticalPageIndex;
@property (nonatomic, assign, readonly) NSUInteger horizontalPageIndex;

/**
 *  是否滚动到顶、底、左、右
 */
@property (nonatomic, assign, readonly) BOOL isScrolledToTop;
@property (nonatomic, assign, readonly) BOOL isScrolledToBottom;
@property (nonatomic, assign, readonly) BOOL isScrolledToLeft;
@property (nonatomic, assign, readonly) BOOL isScrolledToRight;

/** 减速滚动 */
@property (nonatomic, copy) void (^didEndDeceleratingBlock)(UIScrollView *scrollView);

/**
 *  获取offset
 */
- (CGPoint)qs_getTopContentOffset;
- (CGPoint)qs_getBottomContentOffset;
- (CGPoint)qs_getLeftContentOffset;
- (CGPoint)qs_getRightContentOffset;

/**
 *  设置滚动到顶、底、左、右
 */
- (void)qs_scrollToTopAnimated:(BOOL)animated;
- (void)qs_scrollToBottomAnimated:(BOOL)animated;
- (void)qs_scrollToLeftAnimated:(BOOL)animated;
- (void)qs_scrollToRightAnimated:(BOOL)animated;

/**
 *  滚动到指定页码
 *
 *  @param pageIndex 页码
 *  @param scrollDirection QSScrollDirection_Up / QSScrollDirection_Down : 竖直方向;
                           QSScrollDirection_Left / QSScrollDirection_Right : 水平方向;
 *  @param animated 动画
 */
- (void)qs_scrollToPage:(NSInteger)pageIndex scrollDirection:(QSScrollDirection)scrollDirection andAnimated:(BOOL)animated;

/**
 *  滚动到上一页
 *
 *  @param scrollDirection QSScrollDirection_Up / QSScrollDirection_Down : 竖直方向;
                           QSScrollDirection_Left / QSScrollDirection_Right : 水平方向;
 */
- (void)qs_scrollToUpPageWithScrollDirection:(QSScrollDirection)scrollDirection andAnimated:(BOOL)animated;

/**
 *  滚动到下一页
 *
 *  @param scrollDirection QSScrollDirection_Up / QSScrollDirection_Down : 竖直方向;
                           QSScrollDirection_Left / QSScrollDirection_Right : 水平方向;
 */
- (void)qs_scrollToNextPageWithScrollDirection:(QSScrollDirection)scrollDirection andAnimated:(BOOL)animated;
@end
